import type { HotResult } from '@/types/hot.d.ts';
import type { HotItem, BannerItem, CategoryItem, GuessItem } from '@/types/home.d.ts'
import type { PageParams, PageResult } from '@/types/global.d.ts'
import { http } from '@/utils/http.ts'

/**
 * 获取轮播图API
 * @param distributionSite 轮播图位置：1-首页，2-分类 
 * @returns 
 */
export const getHomeBannerAPI = (distributionSite = 1) => {
    return http<BannerItem[]>({
        method: 'GET',
        url: '/home/banner',
        data: {
            distributionSite,
        }
    })
}

export const getHomeCategoryAPI = () => {
    return http<CategoryItem[]>({
        method: 'GET',
        url: '/home/category/mutli',
    })
}

export const getHomeHotAPI = () => {
    return http<HotItem[]>({
        method: 'GET',
        url: '/home/hot/mutli',
    })
}

export const getHomeGoodsGuessLikeAPI = (data?: PageParams) => {
    return http<PageResult<GuessItem>>({
        method: 'GET',
        url: '/home/goods/guessLike',
        data,
    })
}

type HotParams = PageParams & {
    subType?: string
}
/**
 * 通用热门推荐API
 * @param url 请求地址
 * @param data 请求数据
 * @returns 
 */
export const getHotRecommendAPI = (url: string, data?: HotParams) => {
    return http<HotResult>({
        method: 'GET',
        url,
        data,
    })
}